home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / MemBuf.C < prev    next >
C/C++ Source or Header  |  1992-06-25  |  514b  |  34 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "MemBuf.h"
  6. #include "Storage.h"
  7.  
  8. MemBuf::MemBuf(int size, char *p, int count, bool alloc) : StreamBuf(size, p, count, alloc)
  9. {
  10. }
  11.  
  12. int MemBuf::overflow(int c)
  13. {
  14.     if (c != EOF) {
  15.     size_t pos= (size_t) (ptr-base);
  16.     setbuf((char*)Realloc(base, pos*2), pos*2, 0, FALSE);
  17.     ptr= base+pos;
  18.     *ptr++= c;
  19.     }
  20.     return zapeof(c);
  21. }
  22.  
  23. void MemBuf::SwitchToRead()
  24. {
  25.     gptr= ptr;
  26.     ptr= base;
  27.     fpos= 0;
  28. }
  29.  
  30. long MemBuf::ContentsSize()
  31. {
  32.     return gptr-base;
  33. }
  34.